<script type="text/javascript">
        var gk_isXlsx = false;
        var gk_xlsxFileLookup = {};
        var gk_fileData = {};
        function filledCell(cell) {
          return cell !== '' && cell != null;
        }
        function loadFileData(filename) {
        if (gk_isXlsx && gk_xlsxFileLookup[filename]) {
            try {
                var workbook = XLSX.read(gk_fileData[filename], { type: 'base64' });
                var firstSheetName = workbook.SheetNames[0];
                var worksheet = workbook.Sheets[firstSheetName];

                // Convert sheet to JSON to filter blank rows
                var jsonData = XLSX.utils.sheet_to_json(worksheet, { header: 1, blankrows: false, defval: '' });
                // Filter out blank rows (rows where all cells are empty, null, or undefined)
                var filteredData = jsonData.filter(row => row.some(filledCell));

                // Heuristic to find the header row by ignoring rows with fewer filled cells than the next row
                var headerRowIndex = filteredData.findIndex((row, index) =>
                  row.filter(filledCell).length >= filteredData[index + 1]?.filter(filledCell).length
                );
                // Fallback
                if (headerRowIndex === -1 || headerRowIndex > 25) {
                  headerRowIndex = 0;
                }

                // Convert filtered JSON back to CSV
                var csv = XLSX.utils.aoa_to_sheet(filteredData.slice(headerRowIndex)); // Create a new sheet from filtered array of arrays
                csv = XLSX.utils.sheet_to_csv(csv, { header: 1 });
                return csv;
            } catch (e) {
                console.error(e);
                return "";
            }
        }
        return gk_fileData[filename] || "";
        }
        </script><!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>简易手机通讯录</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: Arial, sans-serif;
        }

        body {
            background-color: #1a2533;
            color: #fff;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            padding: 20px;
        }

        .container {
            background-color: #253347;
            padding: 20px;
            border-radius: 10px;
            width: 100%;
            max-width: 500px;
            text-align: center;
        }

        h2 {
            margin-bottom: 20px;
        }

        .input-group {
            margin-bottom: 15px;
            text-align: left;
        }

        .input-group label {
            display: inline-block;
            width: 80px;
        }

        .input-group input {
            padding: 5px;
            border: none;
            border-radius: 5px;
            background-color: #1a2533;
            color: #fff;
            width: calc(100% - 90px);
        }

        textarea {
            width: 100%;
            height: 200px;
            margin-top: 10px;
            padding: 10px;
            border: none;
            border-radius: 5px;
            background-color: #1a2533;
            color: #fff;
            resize: none;
        }

        button {
            background-color: #1da1f2;
            color: #fff;
            border: 2px solid #1da1f2;
            padding: 5px 8px;
            margin: 5px;
            border-radius: 10px;
            cursor: pointer;
        }

        button:hover {
            background-color: #0d8ecf;
        }
    </style>
</head>
<body>
    <div class="container">
        <h2>简易手机通讯录</h2>
        <div class="input-group">
            <label for="name">姓名:</label>
            <input type="text" id="name" placeholder="请输入姓名">
        </div>
        <div class="input-group">
            <label for="phone">电话:</label>
            <input type="tel" id="phone" placeholder="请输入电话号码">
        </div>
        <button id="addBtn">添加</button>
        <button id="queryBtn">查询</button>
        <button id="deleteBtn">删除</button>
        <button id="resetBtn">重置</button>
        <textarea id="contacts" readonly></textarea>
    </div>

    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script src="script.js"></script>
</body>
</html>